﻿using System;
using System.Net;
using System.IO;

namespace NeroConnect.Network
{
    class HttpResponse : IResponse
    {
		private HttpWebResponse _webResponse;

		public HttpResponse(HttpWebResponse webResponse)
		{
			if (webResponse == null)
				throw new ArgumentNullException("webResponse");
			_webResponse = webResponse;
		}

		public WebHeaderCollection Headers
		{
			get { return _webResponse.Headers; }
		}

		public HttpStatusCode StatusCode
		{
			get { return _webResponse.StatusCode; }
		}

		public string StatusDescription
		{
			get { return _webResponse.StatusDescription; }
		}

		public Uri ResponseUri
		{
			get { return _webResponse.ResponseUri; }
		}

		public string ContentType
		{
			get { return _webResponse.ContentType; }
		}

		public long ContentLength
		{
			get { return _webResponse.ContentLength; }
		}

		public string ContentEncoding
		{
			get { return _webResponse.ContentEncoding; }
		}

		public string Server
		{
			get { return _webResponse.Server; }
		}

		public Stream GetResponseStream()
		{
			return new ConnectStream(new LogStream(_webResponse.GetResponseStream()));
		}

		public string GetResponseHeader(string headerName)
		{
			return _webResponse.GetResponseHeader(headerName);
		}

		public void Close()
		{
			_webResponse.Close();
		}

		public CookieCollection Cookies
		{
			get { return _webResponse.Cookies; }
		}

		public DateTime LastModified
		{
			get { return _webResponse.LastModified; }
		}
	}
}
